﻿@{
    var movie = ViewBag.Movie;
    ViewBag.Comments = movie.Comments;
}
<div id="movie" class="row">
    <div class="span6 main-info">
        <div class="page-header">
            <h1>@movie.Title <small>@movie.Year</small>
            </h1>
            <div class="pull-right">
                @if (!String.IsNullOrWhiteSpace(movie.ImdbUrl))
                {
                    <a href="@movie.ImdbUrl" class="btn" target="_blank">IMDb</a>
                }
            </div>
        </div>
        <p>
            @if (!String.IsNullOrWhiteSpace(movie.Rated))
            {
                <span class="label label-info" rel="tooltip" data-original-title="Motion Picture Rating">@movie.Rated</span>
            }
            @if (!String.IsNullOrWhiteSpace(movie.Released))
            {
                <span class="label" rel="tooltip" data-original-title="Release date">@movie.Released</span>
            }
            @if (movie.Runtime > 0)
            {
                <span rel="tooltip" data-original-title="Runtime">@movie.Runtime mins</span>
            }
            <span class="pull-right">
                @if (ViewBag.User.Permissions.Contains("EditMedia"))
                {
                    <a href="@Url.Action("Edit", "Movie", new { @id = ViewBag.Movie.Id })" title="Edit movie">
                        <i class="icon-edit"></i></a>
                }
                @if (ViewBag.User.Permissions.Contains("DeleteMedia"))
                {
                    <a href="@Url.Action("Delete", "Movie", new { @id = ViewBag.Movie.Id })" title="Delete movie">
                        <i class="icon-trash"></i></a>
                }
            </span>
        </p>
        @if (movie.Rating >= 0 && movie.Votes > 0)
        {
            <div class="row">
                <div class="rating progress progress-warning span2 bottom" rel="tooltip" data-original-title="@movie.Rating">
                    <div class="bar" style="width: @movie.RatingPercent%">
                    </div>
                </div>
                <div class="span4">
                    IMDb ratings: <strong>@movie.Rating</strong>/10 from @movie.Votes users
                </div>
            </div>
            <hr />
        }
        <blockquote>
            <p>@movie.Description</p>
        </blockquote>
        <div class="buttons btn-toolbar">
            @if (ViewBag.User.Id > 0)
            {
                <div class="btn-group">
                    <a class="btn btn-success dropdown-toggle" data-toggle="dropdown" href="#"><i class="icon-shopping-cart icon-white">
                                                                                               </i>Add to cart <span class="caret"></span></a>
                    <ul class="dropdown-menu">
                        @foreach (var v in movie.Versions)
                        {
                            <li><a href="@Url.Action("Add", "Cart", new {@versionId = v.Id})">@v.Resolution -
                                    @v.Format<span class="pull-right">@v.Price,-</span></a></li>
                        }
                    </ul>
                </div>
            }
        </div>
    </div>
    <div class="span3">
        <a href="@movie.CoverUrl" class="movie-image">
            <img src="@movie.CoverUrl" alt="" class="thumbnail bottom" rel="tooltip" data-original-title="Click to see fullsize"/>
        </a>
    </div>
</div>
@if (movie.Genres.Count + movie.Languages.Count > 0)
{
    <div class="row">
        <div class="additional-info span9 well">
            @foreach (var g in movie.Genres)
            {
                <a class="label label-inverse" href="Movie/List?genre=@g.Name">@g.Name</a>
            }
            @foreach (var l in movie.Languages)
            {
                <a class="label">@l</a>
            }
        </div>
    </div>
}
else
{
    <hr />

}
@Html.Partial("_MovieTabs")